﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Demo.Extensions;
using Carbon.Web.Forms.Extensions;
namespace Demo.Demos.TravelRequest
{
    public partial class TravelRequest : DemoPage
    {
       protected TravelDataContextControl ctrl_DataContext = null;
        public TravelDataContextControl Control_DataContext
        {
          get
          {
             if (ctrl_DataContext == null) throw new NullReferenceException();
            return ctrl_DataContext;
          }
        }

        
        protected void Click_AddTrip(object sender, EventArgs args)
        {
            Control_DataContext.ViewModel.AddTrip();
        }

        protected void Save_Click(object sender, EventArgs args)
        {
            this.SafeExecute(() =>
            {
                if (!this.ValidateRecursively())
                {
                    throw new ApplicationException("Data not valid");
                }

                throw new ApplicationException("Success");
            });
        }
    }
}